// 20个线程，依次打印1-20最后在Main里打印OK
public class Main {
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            System.out.print("线程1 ");
        });
        Thread t2 = new Thread(()->{
            try {
                t1.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.print("线程2 ");
        });
        Thread t3 = new Thread(()->{
            try {
                t2.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.print("线程3 ");
        });
        Thread t4 = new Thread(()->{
            try {
                t3.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.print("线程4 ");
        });
        Thread t5 = new Thread(()->{
            try {
                t4.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.print("线程5 ");
        });
        Thread t6 = new Thread(()->{
            try {
                t5.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.print("线程6 ");
        });
        Thread t7 = new Thread(()->{
            try {
                t6.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.print("线程7 ");
        });
        Thread t8 = new Thread(()->{
            try {
                t7.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.print("线程8 ");
        });
        Thread t9 = new Thread(()->{
            try {
                t8.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.print("线程9 ");
        });
        Thread t10 = new Thread(()->{
            try {
                t9.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.print("线程10 ");
        });
        Thread t11 = new Thread(()->{
            try {
                t10.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.print("线程11 ");
        });
        Thread t12 = new Thread(()->{
            try {
                t11.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.print("线程12 ");
        });
        Thread t13 = new Thread(()->{
            try {
                t12.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.print("线程13 ");
        });
        Thread t14 = new Thread(()->{
            try {
                t13.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.print("线程14 ");
        });
        Thread t15 = new Thread(()->{
            try {
                t14.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.print("线程15 ");
        });
        Thread t16 = new Thread(()->{
            try {
                t15.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.print("线程16 ");
        });
        Thread t17 = new Thread(()->{
            try {
                t16.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.print("线程17 ");
        });
        Thread t18 = new Thread(()->{
            try {
                t17.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.print("线程18 ");
        });
        Thread t19 = new Thread(()->{
            try {
                t18.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.print("线程19 ");
        });
        Thread t20 = new Thread(()->{
            try {
                t19.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.print("线程20 ");
        });
        t1.start();t2.start();t3.start();t4.start();t5.start();
        t6.start();t7.start();t8.start();t9.start();t10.start();
        t11.start();t12.start();t13.start();t14.start();t15.start();
        t16.start();t17.start();t18.start();t19.start();t20.start();

        try {
            t20.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println("OK");
    }
}
